package cn.edu.zafu.bigdata.yt;

// 子类 Car，继承自 Vehicle
class xCar extends Vehicle {
    // 重写父类的 move 方法
    @Override
    public void move() {
        System.out.println("Car is moving");
    }
}

// 子类 Bicycle，继承自 Vehicle
class xBicycle extends Vehicle {
    // 重写父类的 move 方法
    @Override
    public void move() {
        System.out.println("Bicycle is moving");
    }
}

// 测试类
public class TestPolymorphism {
    public static void main(String[] args) {
        // 定义一个 Vehicle 数组，存储 Car 和 Bicycle 对象
        Vehicle[] vehicles = new Vehicle[2];
        vehicles[0] = new Car();
        vehicles[1] = new Bicycle();

        // 调用它们的 move 方法，展示多态性
        for (Vehicle vehicle : vehicles) {
            vehicle.move();
        }
    }
}
